home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nannws34.zip / TRUNC.PRG < prev   
Text File  |  1989-01-01  |  613b  |  20 lines

  1. * Function: Truncate()
  2. * Author:   A. Timothy Wong
  3. * Version:  Clipper Summer '87
  4. * Note(s):  Truncates a number at a certain decimal place.
  5. *
  6. * Copyright (C) 1988 Nantucket Corp.
  7.  
  8. FUNCTION Truncate
  9. PARAMETERS Number, DecPlaces
  10. PRIVATE RetVal, NStr, Temp1, Temp2
  11.  
  12. NStr = STR(Number)
  13. Temp1 = AT(".",NStr)              && Position of decimal point.
  14. Temp2 = LEN(NStr) - Temp1         && Find total decimal places.
  15. DecPlaces = MIN(Temp2,DecPlaces)  && if Total decimal places is
  16.                                   ** less than needed.
  17. RetVal = VAL(SUBSTR(NStr,1,Temp1 + DecPlaces))
  18.  
  19. RETURN(RetVal)
  20.